import java.util.Random;

public class Lab_02calculation_V02 {
    public static void main(String[] args) {
        Random rand = new Random();
        for (int i = 0; i < 50; i++) {
            int num1, num2, result;
            String operator;

            // 生成加法题目，确保和不超过100
            if (rand.nextBoolean()) {
                num1 = rand.nextInt(100); // 生成0到99之间的随机数
                num2 = rand.nextInt(100 - num1); // 确保加法结果不超过100
                operator = "+";
                result = num1 + num2;
            } else {
                num1 = rand.nextInt(100); // 生成0到99之间的随机数
                num2 = rand.nextInt(num1 + 1); // 确保减法结果不小于0
                operator = "-";
                result = num1 - num2;
            }

            // 每行输出3个题目
            if (i % 3 == 0) {
                System.out.println();
            }

            System.out.printf("%d %s %d = %d\t", num1, operator, num2, result);
        }
    }
}
